package threadcoreknowledge.createthreads.wrongways;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 2.线程池创建线程的方法
 * @Author wushaopei
 * @Date 2021/2/25 8:19
 * @Version 1.0
 */
public class ThreadPool5 {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < 1000; i++) {
            executorService.submit(new Task() {

            });
        }
    }
}

class Task implements Runnable {

    @Override
    public void run() {
        try {
            System.out.println("true =   任务开始执行...");
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName());
    }
}
